package tech.edwardvan.java.methodreference;

import lombok.extern.slf4j.Slf4j;

import java.util.function.Supplier;


/**
 * 方法引用
 * <p>
 * 引用构造函数。例如：Class::new
 *
 * @author EdwardVan
 */
@Slf4j
public class MethodReferenceDemo2 {

    private static void invoke(Supplier<MethodReferenceDemo2> supplier) {
        MethodReferenceDemo2 test = supplier.get();
        test.showName("EdwardVan");
    }

    public void showName(String name) {
        log.info("My name is {}", name);
    }

    public static void main(String[] args) {
        /*
        class 匿名类 implements Supplier<MethodReferenceDemo2> {
            public MethodReferenceDemo2 get() {
                return new MethodReferenceDemo2();
            }
        }
         */
        invoke(MethodReferenceDemo2::new);
    }
}
